package org.example.petsystem.service.impl;
import org.example.petsystem.entity.ResultBody;
import org.example.petsystem.mapper.UserManMapper;
import org.example.petsystem.service.UserManService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
@Service
public class UserManServiceimpl implements UserManService {
    @Autowired
    private UserManMapper userManMapper;
    //显示所有普通用户信息
    @Override
    public List<Map<String,Object>> UserMessage()
    {  if(userManMapper.UserMessage().size()>0)
        return userManMapper.UserMessage();
        return null;
    }
    @Override
    //删除用户
   public  int deleteUser(String phonenumber)
    {
        if(userManMapper.deleteUser(phonenumber) >0)
        {
            return 1;
        }
        else
            return 0;
    }
    //搜索用户
    @Override
    public ResultBody updateUser(Map<String,Object>map)
    {
        if(userManMapper.updateUser(map) > 0&&userManMapper.getUser(map)!=null)
        {
            return new ResultBody(200,"修改成功",userManMapper.getUser(map));
        }
        else
            return new ResultBody(400,"修改失败",false);
    }
}
